using System;
using NUnit.Framework;

namespace Avanzis.QueryObjects.Tests
{
    [TestFixture]
    public class EnumerationTest : BaseTest
    {
        [Test]
        public void TestInt32Enumeration()
        {
            Stadium s1 = new Stadium();
            s1.Code = "XXX";
            s1.Name = "Stadium XXX";
            s1.StadiumType = StadiumType.Big;
            s1.Save();
            
            int statiumCount = Convert.ToInt32(ExecuteScalar("select count(*) from stadiums where code = 'XXX'"));
            Assert.AreEqual(1, statiumCount);

            Stadium s2 = Stadium.FindByPrimaryKey("XXX");
            Assert.AreEqual(StadiumType.Big, s2.StadiumType);

            s2.StadiumType = StadiumType.Small;
            s2.Save();

            Stadium s3 = Stadium.FindByPrimaryKey("XXX");
            Assert.AreEqual(StadiumType.Small, s3.StadiumType);

            s3.Delete();            
        }        
    }
}
